GBML manual / Text

draw_text_warped

Draws text in world space, scaled and rotated - a spinning title, a score that pops, anything draw_text alone cannot do. (x, y) is both the same LEFT/CENTER/RIGHT anchor text_align() already gives draw_text, and this call’s own scale/rotation pivot. Inside a Draw GUI event it is fixed to the screen instead, and (x, y) counts from the screen’s top-left pixel.

Works differently on Game Boy - The Game Boy cannot resize or turn letters, so a turned text keeps its letters upright and puts each 8 pixels of the line on the turn (24 letters at most, drawn with sprites); the size is not used.

Works differently on Game Boy Color - The Game Boy Color cannot resize or turn letters, so a turned text keeps its letters upright and puts each 8 pixels of the line on the turn (24 letters at most, drawn with sprites); the size is not used.

Sega Genesis: not available

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

draw_text_warped(x, y, text, xscale, yscale, angle)

Arguments

NameType
xreal
yreal
textstring
xscalereal
yscalereal
anglereal

Returns

Nothing.

Description

Everything draw_text does, plus its own scale and rotation - a spinning title, a score that pops, a label that leans with whatever it's attached to. (x, y) is exactly the same text_align-resolved anchor draw_text already uses, and it doubles as the pivot this call scales and rotates around - there is nothing extra to set up.

(x, y) is a place in the room, counted from the room's top-left corner. In a Draw GUI event the same call is fixed to the screen instead, and (x, y) counts from the screen's top-left pixel - a score that pops or a warning that shakes, pinned to the screen. See draw_text for the rule.

angle is degrees, 0 = east, counterclockwise - the same convention the angle/direction instance variables already use, so a value that already spins a sprite (angle += 4; in a Step event, say) spins warped text the exact same way. xscale/yscale of 1 and angle of 0 is the plain, unwarped case, and it costs exactly what draw_text costs - nothing extra is reserved or built until a call actually asks for a real scale or rotation.

A negative xscale/yscale mirrors the whole string - draw_text_warped(0, 0, "Hi", -1, 1, 0) draws iH, not Hi with each letter individually backwards. The same convention xscale/yscale and flip_x/flip_y already use on a sprite. 0 still has no sign to flip by, so it still reads as very small text rather than a flip - that part never breaks anything either way. And warped text never costs more than one shared rotation/scale "matrix" per call, no matter how long the string is - the Game Boy Advance only has 32 of those in total, shared with every other rotated or scaled sprite in the game, so this is deliberately cheap. Mirroring is free on a sprite, but not on text: a sprite that is only mirrored needs no matrix, while a mirrored line of text holds its one matrix just as a bigger or turned line does, even though nothing about it is bigger or turned. On the rare project that has already spent all 32 elsewhere, the text still draws - just unwarped for that one frame - rather than not drawing at all.

How far it can turn and grow

The Game Boy Advance draws a stretched or turned sprite only inside a box twice as wide and twice as tall as the sprite itself. Anything that would stick out past that box is cut off, and nothing can make the box bigger. Text is made of sprites, so this decides what warped text can do:

A note on 12. Twelve is how many sprites one drawn thing can use in every game that has not changed Sprites in one drawn thing under Engine limits in Project Settings (it goes up to 32). Wherever this page says 12 letters, it means that number.

What it costs: a scaled or turned word of 12 letters or fewer uses one sprite for each letter, and a plain one (a scale of 1 and no turn) about one for each four. A scaled, turned or mirrored word holds one matrix, however many letters there are; a plain one holds none. The screen can show 128 sprites at once, so a 12-letter word that is scaled costs 12 of them.

Example

draw_text_warped(x, y - 24, "SPIN", 1.5, 1.5, angle);

A label reading SPIN, drawn 50% bigger than normal, 24 pixels above this instance, rotated to match this instance's own current angle - independent of whatever angle does to this instance's own sprite, which is a separate, unrelated field.

A real capture - SPIN drawn 50% bigger and rotated to match the arrow's own angleA real capture - SPIN drawn 50% bigger and rotated to match the arrow's own angle
A real capture - SPIN drawn 50% bigger and rotated to match the arrow's own angle
A real capture, 16 frames played in a loop - the word SPIN above the arrow pops: it jumps up to 1.6 times its normal size, then settles back down to normal size while it rocks a few degrees one way and the other, and then pops again. The arrow does not change. The first frame, which is all a viewer that cannot animate shows, is the word at its biggest, level, with its scale and angle written under the picture.A real capture, 16 frames played in a loop - the word SPIN above the arrow pops: it jumps up to 1.6 times its normal size, then settles back down to normal size while it rocks a few degrees one way and the other, and then pops again. The arrow does not change. The first frame, which is all a viewer that cannot animate shows, is the word at its biggest, level, with its scale and angle written under the picture.
A real capture, 16 frames played in a loop - the word SPIN above the arrow pops: it jumps up to 1.6 times its normal size, then settles back down to normal size while it rocks a few degrees one way and the other, and then pops again. The arrow does not change. The first frame, which is all a viewer that cannot animate shows, is the word at its biggest, level, with its scale and angle written under the picture.

*The same call with the scale and the angle turned into numbers that change (the line under the picture says which): the word pops to 1.6 times its size, settles back to normal size and rocks a few degrees while it does, so it reads like a score that jumps. Sixteen real pictures, two frames apart, played at half the speed of the console. The arrow keeps its angle of 20 and does not change. A viewer that does not animate shows the first frame. The angle stays within 12 degrees either way because that is how a score rocks, not because a bigger turn is a problem: see "How far it can turn and grow" above for what is cut off and when.

On the GBA

Costs ONE shared affine matrix for the whole string, not one per glyph chunk - see draw_text’s own gba note for the font fallback these two calls share. angle is degrees, 0 = east, counterclockwise (the same convention `angle`/`direction` use elsewhere). xscale/yscale of exactly 1 and angle of exactly 0 costs nothing beyond a plain draw_text call - no matrix at all. A word that is scaled or turned and has 12 letters or fewer (or the number set under Engine limits in Project Settings, up to 32) gets a sprite for every letter, so every letter is changed in exactly the same way (and a 12-letter word costs 12 of the 128 sprites the screen can show, where a plain one costs 3); a longer word shares sprites, up to four letters to a sprite, and at a scale that is not a whole number its letters can come out slightly different from one another. A negative xscale/yscale mirrors the whole string, the same convention flip_x/flip_y and a negative xscale/yscale already give a sprite - draw_text_warped(0, 0, "Hi", -1, 1, 0) draws "iH". 0 still has no sign to flip by, so it still reads as very small text rather than a flip. If every one of the hardware’s 32 affine matrices is already in use elsewhere, the text still draws, just unwarped for that frame.

See also: draw_textdraw_text_shearedtext_alignfont_set